//============================================================================
// Name        : FlipAndShift.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Flip and shift in C++, Ansi-style
//============================================================================

#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int numberOfTestCases;
	scanf("%d", &numberOfTestCases);

	for (int i = 0; i < numberOfTestCases; i++) {
		int numberOfDisks;
		int numberOfOddBlacks = 0, numberOfEvenBlacks = 0;

		scanf("%d", &numberOfDisks);
		for (int j = 0; j < numberOfDisks; j++) {
			int disk;
			scanf("%d", &disk);
			if (disk == 1) {
				if ((j + 1) % 2 == 1)
					numberOfEvenBlacks++;
				else
					numberOfOddBlacks++;
			}
		}

		if (numberOfDisks % 2 == 1) {
			printf("YES\n");
		} else if ((numberOfEvenBlacks - numberOfOddBlacks) <= 1
				&& (numberOfEvenBlacks - numberOfOddBlacks) >= -1) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}
